1 /*
2 * Title: S/MIME Project
3 * Description: S/MIME email sending capabilities
4 * @Author Vladimir Radisic
5 * @Version 2.0.1
6 */
7
8 package org.webdocwf.util.smime.util;
9
10
11 /***
12 * Methods of this class are used for displaying byte array on screen in
13 * different forms.
14 */
15 public class Display {
16
17 /***
18 * Prints to screen byte array as hex values
19 * @param in input byte array
20 */
21 public static void printByteArrayAsHex(byte[] in) {
22 if (in.length == 0)
23 System.out.println("Byte array is null!\n");
24 else {
25 for (int i = 0; i != in.length; i++) {
26 if (((i % 16) == 0) && (i != 0))
27 System.out.print("\n");
28 int h = (((int) in[i]) & 0xFF);
29 Integer integ = new Integer(h);
30
31 System.out.print(integ.toHexString(h) + "\t");
32 }
33 System.out.println("\n");
34 }
35 }
36
37 /***
38 * Prints to screen byte array as character string
39 * @param in input byte array
40 */
41 public static void printByteArrayAsChar(byte[] in) {
42 if (in.length == 0)
43 System.out.println("Byte array is null!\n");
44 else {
45 for (int i = 0; i != in.length; i++) {
46 System.out.print((char) in[i]);
47 System.out.print('.');
48 }
49 System.out.println("\n");
50 }
51 }
52
53 /***
54 * Prints to screen byte array
55 * @param in input byte array
56 */
57 public static void printByteArray(byte[] in) {
58 if (in.length == 0)
59 System.out.println("Byte array is null!\n");
60 else {
61 for (int i = 0; i != in.length; i++) {
62 if (((i % 16) == 0) && (i != 0))
63 System.out.print("\n");
64 System.out.print(in[i] + "\t");
65 }
66 System.out.println("\n");
67 }
68 }
69 }
70
This page was automatically generated by Maven